package com.ccjk.beusoft.thirdlib.mockRetrofit.method;

import com.ccjk.beusoft.thirdlib.mockRetrofit.anno.GET;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

import okhttp3.OkHttpClient;
import okhttp3.Request;

/**
 * Created by CCJK on 2017/12/20.
 */

public class ServiceMethod {
    private Method method;
    private Object[] args;

    public ServiceMethod(Method method, Object[] args) {
        this.method = method;
        this.args = args;
        client = new OkHttpClient.Builder()
                .build();
    }

    private OkHttpClient client;

    public Object invoke() throws Throwable {

        GET urlAnno = method.getAnnotation(GET.class);
        String url = urlAnno.value();
        Request.Builder requestBuilder = new Request.Builder();
        requestBuilder.url(url);
        return client.newCall(requestBuilder.build()).execute().body().string();
    }


}
